package com.zbkj.service.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.zbkj.common.model.system.SystemUserLevel;
import com.zbkj.common.model.user.User;
import com.zbkj.common.model.user.UserIntegral;
import com.zbkj.common.model.user.UserIntegralDetail;
import com.zbkj.common.model.user.UserIntegralRecord;
import com.zbkj.common.request.AdminIntegralSearchRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.UserOperateAllIntegralRequest;
import com.zbkj.common.request.UserOperateIntegralMoneyRequest;
import com.zbkj.common.response.UserIntegralRecordResponse;
import com.zbkj.common.response.UserIntegralResponse;

import java.math.BigDecimal;
import java.util.List;

/**
 * 用户积分记录Service
 * +----------------------------------------------------------------------
 * | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 * +----------------------------------------------------------------------
 * | Author: CRMEB Team <admin@crmeb.com>
 * +----------------------------------------------------------------------
 */
public interface UserIntegralService extends IService<UserIntegral> {
    void greenRelease();
    void valueAddTransBalanceDaily();
    void partnerDividendSeason();
    void partnerDividendDaily();

    UserIntegral getInfo();
    Integer getUserId();

    /**
     * 操作积分
     */
    Boolean updateAllIntegral(UserOperateAllIntegralRequest request);


    /**
     * 更新用户积分
     * @param userIntegral 用户积分
     * @param valueAddIntegral 积分
     * @param changeType 增加 0、扣减 1
     * @return 更新后的用户对象
     */
    Boolean updateValueAddIntegral(UserIntegral userIntegral, BigDecimal valueAddIntegral, Integer changeType);
    Boolean updateGreenIntegral(UserIntegral userIntegral, BigDecimal greenIntegral, Integer changeType);
    Boolean updateContributionIntegral(UserIntegral userIntegral, BigDecimal contributionIntegral, Integer changeType);
    Boolean updateBalance(UserIntegral userIntegral, BigDecimal balance, Integer changeType);
    Boolean updateCbfunds(UserIntegral userIntegral, BigDecimal cbfunds, Integer changeType);

    /**
     * 添加/扣减积分
     * @param uid 用户id
     * @param integral 积分
     * @param nowIntegral 历史积分
     * @param changeType 类型：add—添加，sub—扣减
     */
    Boolean operationIntegral(Integer uid, BigDecimal integral, BigDecimal nowIntegral, Integer changeType);
    Boolean operationValueAddIntegralFreeze(Integer uid, BigDecimal integral, BigDecimal nowValueAddIntegral, Integer changeType);
    Boolean operationValueAddIntegral(Integer uid, BigDecimal integral, BigDecimal nowValueAddIntegral, Integer changeType);
    Boolean operationGreenIntegral(Integer uid, BigDecimal integral, BigDecimal nowGreenIntegral, Integer changeType);
    Boolean operationGreenIntegralFreeze(Integer uid, BigDecimal integral, BigDecimal nowGreenIntegral, Integer changeType);
    Boolean operationContributionIntegral(Integer uid, BigDecimal integral, BigDecimal nowContributionIntegral, Integer changeType);
    Boolean operationBalance(Integer uid, BigDecimal integral, BigDecimal nowBalance, Integer changeType);
    Boolean operationCbfunds(Integer uid, BigDecimal integral, BigDecimal nowCbfunds, Integer changeType);

    /**
     * 根据订单编号、uid获取记录列表
     * @param orderNo 订单编号
     * @param uid 用户uid
     * @return 记录列表
     */
    List<UserIntegralDetail> findListByOrderIdAndUid(String orderNo, Integer uid);


    /**
     * PC后台列表
     * @param request 搜索条件
     * @param pageParamRequest 分页参数
     * @return 记录列表
     */
//    PageInfo<UserIntegralResponse> findAdminValueAddList(AdminIntegralSearchRequest request, PageParamRequest pageParamRequest);
//    PageInfo<UserIntegralResponse> findAdminGreenList(AdminIntegralSearchRequest request, PageParamRequest pageParamRequest);
//    PageInfo<UserIntegralResponse> findAdminContributionList(AdminIntegralSearchRequest request, PageParamRequest pageParamRequest);
//    PageInfo<UserIntegralResponse> findAdminBalanceList(AdminIntegralSearchRequest request, PageParamRequest pageParamRequest);
//    PageInfo<UserIntegralResponse> findAdminCbfundsList(AdminIntegralSearchRequest request, PageParamRequest pageParamRequest);

    /**
     * 根据类型条件计算积分总数
     * @param uid 用户uid
     * @return 积分总数
     */
    UserIntegral getSumValueAddIntegral(Integer uid);
    UserIntegral getSumGreenIntegral(Integer uid);
    BigDecimal getSumContributionIntegral(Integer uid);
    BigDecimal getSumBalance(Integer uid);

    BigDecimal getSumCbfunds(Integer uid);

//    /**
//     * H5用户积分列表
//     * @param uid 用户uid
//     * @param pageParamRequest 分页参数
//     * @return List
//     */
//    List<UserIntegral> findUserValueAddIntegralList(Integer uid, PageParamRequest pageParamRequest);
//    List<UserIntegral> findUserGreenIntegralList(Integer uid, PageParamRequest pageParamRequest);
//    List<UserIntegral> findUserContributionIntegralList(Integer uid, PageParamRequest pageParamRequest);
//    List<UserIntegral> findUserBalanceList(Integer uid, PageParamRequest pageParamRequest);
//    List<UserIntegral> findUserCbfundsList(Integer uid, PageParamRequest pageParamRequest);

}
